
<div class="section" id="khuvuclist">

	<div class="section-title">Quản lý phân phối báo</div>
    
    <div class="section-content padding1">
    	<div class="button right">
        	<a class="button save" onclick="save()">Lưu</a>
			<a class="button cancel" href="?route=deliman/phieuphanphoi">Bỏ qua</a>    
            
        </div>
        <div class="clearer">^&nbsp;</div>
    
    	<form name="frm" id="frm" action="<?php echo $action?>" method="post" enctype="multipart/form-data">
        
        	<input type="hidden" name="phieuphanphoiid" value="<?php echo $item['phieuphanphoiid']?>">
            <input type="hidden" name="kybaoid" value="<?php echo $item['kybaoid']?>">
            <input type="hidden" name="loaibaoid" value="<?php echo $item['loaibaoid']?>">
        	<div id="error" class="error" style="display:none"></div>
            
        	
            	
            <div id="fragment-thongtin">
            	<table class="table-form">
                	<tr>
                    	<td><label>Mã phiếu:</label></td>
                        <td><?php echo $item['maphieuphanphoi']?></td>
                    </tr>
                    
                    <tr>
                    	<td><label>Ngày lập:</label></td>
                        <td><?php echo $this->date->formatMySQLDate($item['ngaylap'])?></td>
                    </tr>
                    <tr>
                    	<td><label>Đầu báo:</label></td>
                        <td>
                        	<?php echo $item['tenloaibao']?>
                        	
                            <label>Kỳ báo:</label>
                     		<?php echo $item['tenkybao']?>
                            <label>Ngày phát hành:</label>
                     		<?php echo $this->date->formatMySQLDate($item['ngayphathanh'])?>
                        </td>
                    </tr>
                    <tr>
                    	<td><label>Tổng chỉ tiêu:</label></td>
                        <td><?php echo $this->string->numberFormate($item['chitieu'])?></td>
                    </tr>
                    <tr>
                    	<td><label>Ghi chú:</label></td>
                        <td><?php echo $item['ghichu']?></td>
                    </tr>
                    <tr>
                    	<td><label>Khu vực quản lý phân phối:</label></td>
                        <td>
                        	<select id="khuvucphanphoi">
                            	<?php foreach($khuvucquanlys as $kv){ ?>
                            	<option value="<?php echo $kv['khuvucid']?>"><?php echo $kv['tenkhuvuc']?> <?php echo $kv['tenphuongxa']?> <?php echo $kv['tenquanhuyen']?> <?php echo $kv['tentinhthanh']?></option>
                                <?php } ?>
                            </select>
                        </td>
                    </tr>
                </table>
                
            </div>
            <link href="<?php echo DIR_VIEW?>css/jquery.treeTable.css" rel="stylesheet" type="text/css" />
			  <script type="text/javascript" src="<?php echo DIR_VIEW?>js/jquery.treeTable.js"></script>
              <script type="text/javascript">
              $(document).ready(function() {
                // TODO Fix issue with multiple treeTables on one page, each with different options
                // Moving the #example3 treeeTable call down will break other treeTables that are expandable...
                //$(".example").treeTable();
              });
              
              </script>
            <div id="khuvucphanphoishow" class="khuvuc treeindex">
                  
            </div> 
            
                
            
            
        </form>
    
    </div>
    
</div>

<script language="javascript">
$('#khuvucphanphoi').change(function(e) {
    $('#khuvucphanphoishow').load('?route=deliman/phieuphanphoi/loadKhuVucPhanPhoi&khuvucid='+this.value+"&phieuphanphoiid=<?php echo $item['phieuphanphoiid']?>",function(){
		$(".example").treeTable();
		
		numberReady();
		
	});
});

$(document).ready(function(e) {
	$('#khuvucphanphoi').change();
});



<!--thực hiện chức năng save dữ liệu-->
function save()
{
	$.blockUI({ message: "<h1>Please wait...</h1>" }); 
	
	$.post("?route=deliman/phieuphanphoi/savephanphoikhuvuc", $("#frm").serialize(),
		function(data){
			if(data == "true")
			{
				//window.location = "?route=deliman/phieuphanphoi";
				alert("Lưu phân phối khu vực thành công");
			}
			else
			{
			
				$('#error').html(data).show('slow');
				
				
			}
			$.unblockUI();
		}
		
	);
}
</script>
